package org.hazelnuts.dao.impl;

import org.hazelnuts.accessor.MysqlJdbcAccessor;
import org.hazelnuts.dao.UserRepository;
import org.hazelnuts.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("userRepository")
public class UserRepositoryImpl implements UserRepository {

    @Autowired
    private MysqlJdbcAccessor mysqlJdbcAccessor;

    @Override
    public int create(User user) {
        String sqlString = "INSERT INTO t_jdbc_user (name, age, text) VALUES(?, ?, ?)";
        return mysqlJdbcAccessor.create(sqlString, user.getName(), user.getAge(), "Test Script");
    }

    @Override
    public int update(User user) {
        return 0;
    }

    @Override
    public int delete(int id) {
        return 0;
    }

    @Override
    public User findById(int id) {
        return null;
    }

    @Override
    public int testSql() {
        return mysqlJdbcAccessor.query();
    }
}
